import time

from selenium.webdriver.common.by import By

from base.page_base import BasePage


class LoginPage(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        self.username = (By.XPATH, '//*[@id="keywords"]')
        self.password = (By.XPATH, '//*[@id="password"]')
        self.login_btn = (By.XPATH, '//*[@id="login-btn"]')
        self.success_result = (By.XPATH, '//*[@id="mlayout"]/div[1]/div[1]/div/div[2]/li[1]/span/a')
        self.error_result = (By.XPATH, '//*[@id="err"]/span')

    def login(self, username, password):
        self.base_input(self.username, username)
        self.base_input(self.password, password)
        self.base_click(self.login_btn)

    def get_success_result(self):
        return self.fd_element(self.success_result).text

    def get_error_result(self):
        return self.fd_element(self.error_result).text
        # 获取注册结果


